package com.app.controller.miniprogram;

import com.app.common.Result;
import com.app.model.NoticeModel;
import com.app.service.NoticeService;
import com.app.service.UserService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@Controller
@RequestMapping("/jtwq")
public class NoticeController {
    @Autowired
    private NoticeService noticeService;


    @Autowired
    UserService userService;
    /**
     * 通知公告列表
     * @return
     * @throws Exception
     */
    @GetMapping("/getNoticeList")
    public Result<Object> getNoticeList(){
        NoticeModel model = new NoticeModel();
        model.setPage(1);
        model.setLimit(3);
        Page<NoticeModel> modelPage = noticeService.getPageByModel(model);
        return Result.success(modelPage.getRecords());
    }

    /**
     * 根据ID查询
     * @return
     * @throws Exception
     */
    @GetMapping("/getNoticeById")
    public Result<Object> getNoticeById(HttpServletRequest request, Integer id){

        NoticeModel model = noticeService.getModelBtId(id);
        return Result.success(model);
    }

}
